package org.wtj.v2;

import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;

/**
 * 定义一个名为ASCIIArt的命令行工具，包含字体大小和要转换为ASCII艺术的单词参数
 */
@Command(name = "ASCIIArt", version = "ASCIIArt 1.0", mixinStandardHelpOptions = true)
public class ASCIIArt implements Runnable {

    // 设置字体大小的选项，默认值为19
    @Option(names = { "-s", "--font-size" }, description = "Font size")
    int fontSize = 19;

    // 设置要转换为ASCII艺术的单词参数，默认值为"Hello, picocli"
    @Parameters(paramLabel = "<word>", defaultValue = "Hello, picocli",
               description = "Words to be translated into ASCII art.")
    private String[] words = { "Hello,", "picocli" };

    /**
     * 实现Runnable接口的run方法，输出字体大小和单词参数
     */
    @Override
    public void run() {
        // 自己实现业务逻辑
        System.out.println("fontSize = " + fontSize);
        System.out.println("words = " + String.join(",", words));
    }

    /**
     * 程序的入口点，使用CommandLine库执行ASCIIArt命令
     * @param args
     */
    public static void main(String[] args) {
        // 注：这里接受参数 args，完成命令行参数的解析和执行。目前我们只是模拟参数
        String[] arg = new String[]{"-s","20","Hello, picocli"};
        int exitCode = new CommandLine(new ASCIIArt()).execute(arg);
        System.exit(exitCode);
    }
}

